layui.use(['table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
      * Outbound Order Details Management 出库订单明细表管理
      */
    var OutOrderDetailed = {
        tableId: "outOrderDetailedTable"
    };

    /**
     * Initialize Table Columns 初始化表格的列
     */
    OutOrderDetailed.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: 'Primary Key'},
            {field: 'detailedGoodsname', sort: true, title: 'Product Name', style:'background-color: #dbf1e1;font-weight: 600;',width:200},
            {field: 'detailedGoodscode', sort: true, title: 'Product Code', style:'background-color: #dbf1e1;font-weight: 600;',width:130},
            {field: 'goodsNo', title: 'Item No.', style:'background-color: #dbf1e1;font-weight: 600;', totalRowText: 'Total:'},
            {field: 'detailedNumber', sort: true, title: 'Quantity', totalRow: true, style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'detailedDate', sort: true, title: 'Production Date', style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'detailedBatchnumber', sort: true, title: 'Batch No.', style:'background-color: #dbf1e1;font-weight: 600;',width: 140},
            {field: 'detailedPrice', sort: true, title: 'Unit Price'},
            {field: 'detailedMoney', sort: true, title: 'Amount', totalRow: true},
            {field: 'detailedOutVolume', sort: true, title: 'Volume', totalRow: true},
            {field: 'detailedOutWeight', sort: true, title: 'Weight', totalRow: true},
            {field: 'detailedLargeclass', title: 'Product Category'},
            {field: 'detailedGoodstype', title: 'Type', hide: true},
            {field: 'goodsUnit', title: 'Unit'},
            {field: 'detailedPacking', title: 'Packaging'},
            {field: 'goodsSpecs', title: 'Specifications'},
        ]];
    };

    /**
     * Click Search Button 点击查询按钮
     */
    OutOrderDetailed.search = function () {
        var queryData = {};
        queryData['condition'] = $("#condition").val();
        table.reload(OutOrderDetailed.tableId, {
            where: queryData, page: {curr: 1},
             done:function () {
            }
        });
    };

    // Render table 渲染表格
    var tableResult = table.render({
        elem: '#' + OutOrderDetailed.tableId,
        url: Feng.ctxPath + '/outOrderDetailed/list?detailedOutNumber='+$("#detailedOutNumber").val(),
        page: true,
        limit: 40,
        height: "full-60",
        toolbar: '#toolbarfrom',
        totalRow: true ,//开启合计行
        cellMinWidth: 100,
        cols: OutOrderDetailed.initColumn()
    });

    // Search button click event 搜索按钮点击事件
    $('#btnSearch').click(function () {
        OutOrderDetailed.search();
    });
});
